//
//  WrongWordCell.m
//  HotWord
//
//  Created by Rainbow on 9/2/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "WrongWordCell.h"
#import "Meaning.h"

@implementation WrongWordCell
@synthesize englishLabel;
@synthesize chineseLabel;
@synthesize word;
@synthesize deleteBtn;
@synthesize transScroll;
@synthesize myDelegate;
@synthesize cellIndex;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

-(IBAction)deleteBtnPressed:(id)sender
{
    if ([myDelegate respondsToSelector:@selector(WrongWordCellDidRemove:)]) {
        [myDelegate WrongWordCellDidRemove:self];
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

-(void)setWrongWord:(Word *)wrongWord
{
    self.word = wrongWord;
    englishLabel.text = wrongWord.content;
    // chineseLabel.text = [wrongWord.tanses objectAtIndex:0];
    
    //WrongWordCell *wrongwordcell;
    //[transScroll ];
    transScroll.pagingEnabled = YES;
    // transScroll.delegate = self;
    transScroll.showsHorizontalScrollIndicator = NO;
    
    for (UIView *view in [transScroll subviews]) {
        [view removeFromSuperview];
    }
    
    int  transCount=[wrongWord.meanings count];
    for (int j = 0 ; j < transCount; j++) {
        
        
        UILabel *transLabel=[[[UILabel alloc]initWithFrame:CGRectMake(150 * j , 0, 150 , 31)] autorelease];
        
        transLabel.backgroundColor=[UIColor clearColor];
        transLabel.textAlignment = UITextAlignmentLeft;
        
        Meaning *meaning = [word.meanings objectAtIndex:j];
        
        transLabel.text = meaning.chineseTranslate;
        transLabel.font = [UIFont systemFontOfSize:12];
        [transLabel setUserInteractionEnabled:NO];
        [transScroll addSubview:transLabel];
    }
    
    transScroll.contentSize = CGSizeMake(150* transCount , 31);
    
}


- (void)dealloc
{
    [englishLabel release];
    [chineseLabel release];
    [word release];
    [super dealloc];
}

@end
